﻿using B.S.DataBase.MyProject.ErrorCode;
using MediatR;
using MedicalPCTerminal.Write.API.Appcation.Commands.知识管理;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace MedicalPCTerminal.Write.API.Controllers
{
    /// <summary>
    /// 知识管理的控制器-写
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class KnowledgeController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator"></param>
        public KnowledgeController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 知识管理-我的知识的数据修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> Handle(UdpKnowledgeCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 知识管理-我的知识的状态更改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> UdpKnowledgeStatus(UdpKnowledgeStatusCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }



    }

}
